﻿using Ninject;
using Ninject.Modules;

namespace Lucas.Wendell.PI.Infrastructure.NinjectSLC
{
    public static class Kernel
    {
        private static IKernel kernel = new StandardKernel(new NinjectModule[] { new Module() });

        /// <summary>
        /// Método Responsável por obter instância concreta do serviço solicitado
        /// </summary>
        /// <param name="serviceType"></param>
        /// <returns></returns>
        public static object GetInstance(System.Type serviceType)
        {
            return kernel.TryGet(serviceType);
        }

        public static T GetInstance<T>(System.Type serviceType)
        {
            return (T)kernel.TryGet(serviceType);
        }

        public static System.Collections.Generic.IEnumerable<object> ObterDependencias(System.Type serviceType)
        {
            return kernel.GetAll(serviceType);
        }
    }
}
